﻿namespace PMS.Client.FrmUserPositionLevel
{
    using DevComponents.DotNetBar;
    using DevComponents.Editors;
    using PMS.BLL;
    using PMS.Model;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmUpdate : Form
    {
        private string activeOrganName = "";
        private OrganPositionLevelBLL bll = new OrganPositionLevelBLL();
        private Button btnCancel;
        private Button btnSave;
        private IContainer components = null;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label8;
        private IntegerInput LevelA;
        private IntegerInput LevelB;
        private IntegerInput LevelC;
        private OrganPositionLevel model = null;
        private TextBox Organname;

        public FrmUpdate(string activeOrganName)
        {
            this.InitializeComponent();
            this.activeOrganName = activeOrganName;
            this.Organname.Text = this.activeOrganName;
            this.model = this.bll.GetModel(this.activeOrganName);
            if (this.model != null)
            {
                this.LevelA.Text = this.model.LevelA.ToString();
                this.LevelB.Text = this.model.LevelB.ToString();
                this.LevelC.Text = this.model.LevelC.ToString();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.model == null)
            {
                this.model = new OrganPositionLevel();
                this.model.OrganName = this.activeOrganName;
                this.model.LevelA = new int?(this.LevelA.Value);
                this.model.LevelB = new int?(this.LevelB.Value);
                this.model.LevelC = new int?(this.LevelC.Value);
                this.bll.Add(this.model);
                base.DialogResult = DialogResult.OK;
            }
            else
            {
                this.model.OrganName = this.activeOrganName;
                this.model.LevelA = new int?(this.LevelA.Value);
                this.model.LevelB = new int?(this.LevelB.Value);
                this.model.LevelC = new int?(this.LevelC.Value);
                if (this.bll.Update(this.model))
                {
                    base.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("更新失败！");
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.Organname = new TextBox();
            this.label8 = new Label();
            this.label1 = new Label();
            this.LevelC = new IntegerInput();
            this.LevelA = new IntegerInput();
            this.label2 = new Label();
            this.LevelB = new IntegerInput();
            this.label3 = new Label();
            this.btnCancel = new Button();
            this.btnSave = new Button();
            this.LevelC.BeginInit();
            this.LevelA.BeginInit();
            this.LevelB.BeginInit();
            base.SuspendLayout();
            this.Organname.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.Organname.BorderStyle = BorderStyle.FixedSingle;
            this.Organname.Location = new Point(0x81, 0x13);
            this.Organname.Name = "Organname";
            this.Organname.ReadOnly = true;
            this.Organname.Size = new Size(0xc9, 0x15);
            this.Organname.TabIndex = 13;
            this.label8.AutoSize = true;
            this.label8.Location = new Point(0x44, 0x15);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x35, 12);
            this.label8.TabIndex = 12;
            this.label8.Text = "机构名称";
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x22, 0x3b);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x59, 12);
            this.label1.TabIndex = 14;
            this.label1.Text = "工勤岗编制人数";
            this.LevelC.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelC.BackgroundStyle.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelC.BackgroundStyle.BackColor2 = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelC.BackgroundStyle.BorderBottom = eStyleBorderType.Solid;
            this.LevelC.BackgroundStyle.BorderColor = Color.FromArgb(0x66, 0x66, 0x66);
            this.LevelC.BackgroundStyle.BorderLeft = eStyleBorderType.Solid;
            this.LevelC.BackgroundStyle.BorderRight = eStyleBorderType.Solid;
            this.LevelC.BackgroundStyle.BorderTop = eStyleBorderType.Solid;
            this.LevelC.BackgroundStyle.Class = "DateTimeInputBackground";
            this.LevelC.Location = new Point(0x81, 0x3b);
            this.LevelC.Name = "LevelC";
            this.LevelC.Size = new Size(0xc9, 0x15);
            this.LevelC.TabIndex = 15;
            this.LevelA.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelA.BackgroundStyle.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelA.BackgroundStyle.BackColor2 = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelA.BackgroundStyle.BorderBottom = eStyleBorderType.Solid;
            this.LevelA.BackgroundStyle.BorderColor = Color.FromArgb(0x66, 0x66, 0x66);
            this.LevelA.BackgroundStyle.BorderLeft = eStyleBorderType.Solid;
            this.LevelA.BackgroundStyle.BorderRight = eStyleBorderType.Solid;
            this.LevelA.BackgroundStyle.BorderTop = eStyleBorderType.Solid;
            this.LevelA.BackgroundStyle.Class = "DateTimeInputBackground";
            this.LevelA.Location = new Point(0x81, 0x5d);
            this.LevelA.Name = "LevelA";
            this.LevelA.Size = new Size(0xc9, 0x15);
            this.LevelA.TabIndex = 0x11;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(0x22, 0x60);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x59, 12);
            this.label2.TabIndex = 0x10;
            this.label2.Text = "管理岗编制人数";
            this.LevelB.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelB.BackgroundStyle.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelB.BackgroundStyle.BackColor2 = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LevelB.BackgroundStyle.BorderBottom = eStyleBorderType.Solid;
            this.LevelB.BackgroundStyle.BorderColor = Color.FromArgb(0x66, 0x66, 0x66);
            this.LevelB.BackgroundStyle.BorderLeft = eStyleBorderType.Solid;
            this.LevelB.BackgroundStyle.BorderRight = eStyleBorderType.Solid;
            this.LevelB.BackgroundStyle.BorderTop = eStyleBorderType.Solid;
            this.LevelB.BackgroundStyle.Class = "DateTimeInputBackground";
            this.LevelB.Location = new Point(0x81, 0x80);
            this.LevelB.Name = "LevelB";
            this.LevelB.Size = new Size(0xc9, 0x15);
            this.LevelB.TabIndex = 0x13;
            this.label3.AutoSize = true;
            this.label3.Location = new Point(12, 0x83);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x71, 12);
            this.label3.TabIndex = 0x12;
            this.label3.Text = "专业技术岗编制人数";
            this.btnCancel.BackColor = Color.White;
            this.btnCancel.FlatStyle = FlatStyle.Popup;
            this.btnCancel.Location = new Point(0xff, 0xad);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 0x15;
            this.btnCancel.Text = "关闭";
            this.btnCancel.UseVisualStyleBackColor = false;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnSave.BackColor = Color.White;
            this.btnSave.FlatStyle = FlatStyle.Popup;
            this.btnSave.Location = new Point(0x81, 0xad);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new Size(0x4b, 0x17);
            this.btnSave.TabIndex = 20;
            this.btnSave.Text = "保存";
            this.btnSave.UseVisualStyleBackColor = false;
            this.btnSave.Click += new EventHandler(this.btnSave_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            base.ClientSize = new Size(0x1a3, 0xd8);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnSave);
            base.Controls.Add(this.LevelB);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.LevelA);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.LevelC);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.Organname);
            base.Controls.Add(this.label8);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FrmUpdate";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "修改机定岗位编制人数";
            this.LevelC.EndInit();
            this.LevelA.EndInit();
            this.LevelB.EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

